package main

import (
	"fmt"
	"strconv"
	"strings"
	"time"
)

func main() {

	start := time.Now()
	num := 12345679000000000000000000000000000000000000000000000000000.8

	for i := 0 ; i < 1000; i ++ {
		FloatFormat(5, num)
	}
	fmt.Println(time.Since(start))
}

func FloatFormat(bit int, num float64) (str string) {
	str = strconv.FormatFloat(num, 'f', bit, 64)
	if len(str) < 4 {
		return str
	}
	arr := strings.Split(str, ".")
	length := len(arr[0])
	if length < 4 {
		return str
	}
	count := (length - 1) / 3
	for i := 0; i < count; i++ {
		arr[0] = arr[0][:length-(i+1)*3] + "," + arr[0][length-(i+1)*3:]
	}
	return strings.Join(arr, ".")
}
